package com.beans;

import java.sql.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.*;

public class CommentForm extends ActionForm{
	
	int id;
	String description;
	String createdById;
	Date  createdDate;
	int   noticeId;
	String Creatorname;
	
	public String getCreatorname() {
		return Creatorname;
	}
	public void setCreatorname(String creatorname) {
		Creatorname = creatorname;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getCreatedById() {
		return createdById;
	}
	public void setCreatedById(String createdById) {
		this.createdById = createdById;
	}
	public Date getCreatedDate() {
		return createdDate;
	}
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	public int getNoticeId() {
		return noticeId;
	}
	public void setNoticeId(int noticeId) {
		this.noticeId = noticeId;
	}
		
	@Override
	public String toString() 
	{
			return "[ "+id+","+description+","+Creatorname+"] ,";			
	} 
	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		ActionError error;
		System.out.println("Validate method is called");

		if (description == null || description.length() == 0) {
			error = new ActionError("comment.commentDescriptionRequired");
			errors.add("comments", error);
		}
		
		else if (description.length()>100) {
			error = new ActionError("comment.commentlengthRequired");
			errors.add("commentlength", error);
		}
		return errors;
	}
	

}
